Bitmap Shapes
Bitmap shapes allow you to create images for which you specify the color value of each pixel. Geometric shapes create images with more flexibility--they can be rendered by QuickDraw GX accurately at any output device resolution. However, you might still want to use bitmap shapes for a number of reasons. For example, if you know the resolution of an output device, you can create a bitmap shape to use as an offscreen graphics buffer. As another example, since bitmaps allow you to specify multiple colors within a single shape, you can use bitmaps to create gradients, or ramps--shapes that fade from one color to another.Figure 1-11 shows some sample bitmaps.
Figure 1-11 Sample bitmap shapes
Although there are many types of geometric shapes--points, lines, curves, and so on--there is only one type of bitmap shape. Bitmap shapes make extensive use of their geometry property. In fact, most of the information useful to bitmap shapes is stored in their geometry--the values of the bitmap's pixels, the dimensions of the bitmap, and the color information used by the bitmap.
Bitmap shapes don't make much use of their shape fill property, and they use very little of their associated style object. In fact, the only pieces of information in a style object used by bitmap shapes are the style attributes that determine whether the upper-left corner of the bitmap should be constrained to an integer grid position.
Because bitmap shapes store their own color information in their geometries, they don't use the color property of their ink object. They do, however, use the transfer mode property of their ink objects.
Bitmap shapes make full use of their transform objects. For example, you can scale, skew, rotate, and clip bitmap shapes. You can also hit-test bitmap shapes, but you cannot hit-test parts of a bitmap shape as you can for other types of shapes. For more information about transform objects and hit-testing, see the chapter "Transform Objects" and the chapter "Shape Objects" of Inside Macintosh: QuickDraw GX Objects.
Figure 1-12 shows a bitmap shape object and bitmap geometry.
As Figure 1-12 shows, a bitmap geometry contains a reference to a pixel image, which contains the color values of each pixel in the bitmap. QuickDraw GX allows pixel images to be stored in three locations:
Each of these options presents different advantages and disadvantages. For example, storing a pixel image in a disk file allows you to have large bitmaps without keeping the entire pixel image in memory. However, QuickDraw GX provides only limited access to this type of pixel image: it can read the image, but cannot make changes to it.
- in memory allocated by your application
- in memory allocated and managed by QuickDraw GX
- in a disk file
Different bitmap shapes may reference the same pixel image. You might want to use this feature to draw the same pixel image with two different transfer modes, for example, or to draw the same pixel image in two different color spaces.
The other fields of a bitmap geometry define the dimensions, color information, and position of the bitmap's pixel image. Figure 1-13 shows a sample bitmap geometry that uses one bit to represent each pixel, and has four rows and ten columns. Since each row of the pixel image requires only ten bits, the pixel image is padded so that each row is represented by an even number of bytes.
Figure 1-13 Elements of a bitmap geometry
The color space and color set fields of the bitmap geometry allow you to specify how QuickDraw GX should interpret the pixel values. In this example, pixel values of 0 represent white pixels and pixel values of 1 represent black pixels.
The color profile field specifies color-matching information. See the chapter "Color-Related Objects" in Inside Macintosh: QuickDraw GX Objects for more information about color values, color spaces, color sets, and color matching.
For more information about bitmap shapes, see the chapter "Bitmap Shapes" in this book.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help